export default function(config={}){
    const {url,params={},jsonp="callback"} = config;
    return new Promise(function(resolve,reject){
        const fnName = "yuma"+Math.random().toString(36).slice(2)+Date.now();
        window[fnName] = resolve;
        const script = document.createElement("script");
        script.src = url;
        params[jsonp] = fnName;
        script.src += "?" + Object.keys(params).map(key=>key+"="+params[key]).join("&");
        script.onload = function(){
            delete window[fnName];
            document.body.removeChild(script);
        }
        document.body.appendChild(script);
    })
}